From f1798afadb87ade73981485a67a5a477c67a9076 Mon Sep 17 00:00:00 2001 From: "robertlipe@gmail.com" Date: Tue, 26 Jul 2011 03:41:14 +0000 Subject: [PATCH] Whew. Work through the last of the changes. The entire project builds AND runs the test suite on Mac when built with either configure/make as C or via Qmake/make as C++. Now we can start fretting about things like using QTime to replace time_t and how we're going to distribute Mae command line builds... git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4078 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/GPSBabel.pro | 14 +++++++------- gpsbabel/an1sym.h | 2 +- gpsbabel/brauniger_iq.c | 11 +++++++++-- gpsbabel/coto.c | 6 +++--- gpsbabel/delbin.c | 23 +++++++++++++++-------- gpsbabel/destinator.c | 2 +- gpsbabel/garmin_txt.c | 20 ++++++++++++++++---- gpsbabel/gcdb.c | 12 ++++++------ gpsbabel/gdb.c | 2 +- gpsbabel/geoniche.c | 8 ++++---- gpsbabel/ggv_log.c | 2 +- gpsbabel/ggv_ovl.c | 2 +- gpsbabel/gpilots.c | 8 ++++---- gpsbabel/igc.c | 11 +++++++++-- gpsbabel/mag_pdb.c | 2 +- gpsbabel/maggeo.c | 2 +- gpsbabel/magnav.c | 2 +- gpsbabel/mapsend.c | 8 ++++++-- gpsbabel/mapsource.c | 14 +++++++------- gpsbabel/navicache.c | 3 ++- gpsbabel/overlay.c | 2 +- gpsbabel/palmdoc.c | 4 ++-- gpsbabel/pathaway.c | 12 ++++++------ gpsbabel/pdbfile.c | 20 ++++++++++---------- gpsbabel/pocketfms_bc.c | 2 +- gpsbabel/shape.c | 6 +++--- gpsbabel/skytraq.c | 18 +++++++++--------- gpsbabel/stmsdf.c | 6 +++--- gpsbabel/stmwpp.c | 2 +- 29 files changed, 132 insertions(+), 94 deletions(-) diff --git a/gpsbabel/GPSBabel.pro b/gpsbabel/GPSBabel.pro index 9d2e92546..0ed184b41 100644 --- a/gpsbabel/GPSBabel.pro +++ b/gpsbabel/GPSBabel.pro @@ -28,9 +28,9 @@ ALL_FMTS=$$MINIMAL_FMTS gtm.cc gpsutil.cc pcx.cc cetus.cc copilot.cc \ jtr.cc sbp.cc sbn.cc mmo.cc skyforce.cc itracku.cc v900.cc delbin.cc \ pocketfms_bc.cc pocketfms_fp.cc pocketfms_wp.cc naviguide.cc enigma.cc \ vpl.cc teletype.cc jogmap.cc bushnell.cc bushnell_trl.cc wintec_tes.cc \ - subrip.cc garmin_xt.cc explorist_ini.cc \ + subrip.cc garmin_xt.cc \ -ALL_FMTS=$$MINIMAL_FMTS +# ALL_FMTS=$$MINIMAL_FMTS FILTERS=position.cc radius.cc duplicate.cc arcdist.cc polygon.cc smplrout.cc \ reverse_route.cc sort.cc stackfilter.cc trackfilter.cc discard.cc \ nukedata.cc interpolate.cc transform.cc height.cc swapdata.cc @@ -86,9 +86,9 @@ macx { SOURCES += $$ALL_FMTS $$FILTERS $$SUPPORT $$SHAPE $$ZLIB $$JEEPS # We don't care about stripping things out of the build. Full monty, baby. -#DEFINES += MAXIMAL_ENABLED +DEFINES += MAXIMAL_ENABLED DEFINES += FILTERS_ENABLED -#DEFINES += PDBFMTS_ENABLED -#DEFINES += SHAPELIB_ENABLED -#DEFINES += CSVFMTS_ENABLED -#DEFINES += CET_WANTED +DEFINES += PDBFMTS_ENABLED +DEFINES += SHAPELIB_ENABLED +DEFINES += CSVFMTS_ENABLED +DEFINES += CET_WANTED diff --git a/gpsbabel/an1sym.h b/gpsbabel/an1sym.h index 8cbdcd4f5..c2ef4582c 100644 --- a/gpsbabel/an1sym.h +++ b/gpsbabel/an1sym.h @@ -725,7 +725,7 @@ int FindIconByGuid(GUID* guid, char** name) int i = 0; for (i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) { if (!memcmp(guid, &default_guids[i].guid, sizeof(GUID))) { - *name = default_guids[i].name; + *name = (char*) default_guids[i].name; return 1; } } diff --git a/gpsbabel/brauniger_iq.c b/gpsbabel/brauniger_iq.c index 43f00122a..30d0024b3 100644 --- a/gpsbabel/brauniger_iq.c +++ b/gpsbabel/brauniger_iq.c @@ -27,7 +27,7 @@ static void* serial_handle; #define MYNAME "BRAUNIGER-IQ" #define PRESTRKNAME "PRESALTTRK" -static enum { +typedef enum { st_sync, st_fl_num, st_data_len, @@ -45,7 +45,14 @@ static enum { st_sample_alt, st_sample_spd, num_states -} state; +} state_t; +state_t state; +#if __cplusplus +inline state_t operator++(state_t& rs, int) +{ + return rs = (state_t)((int)rs + 1); +} +#endif static const int reqd_bytes[num_states] = { 6, 1, 2, 2, 25, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1 }; diff --git a/gpsbabel/coto.c b/gpsbabel/coto.c index 1219335ba..a08d7b74d 100644 --- a/gpsbabel/coto.c +++ b/gpsbabel/coto.c @@ -358,7 +358,7 @@ coto_wpt_write(const waypoint* wpt) if ((wpt->description) && ((strlen(wpt->description) > MAX_MARKER_NAME_LENGTH) || (strcmp(wpt->description, wpt->shortname)))) { if ((wpt->notes) && (strcmp(wpt->description, wpt->notes) != 0)) { - notes = xcalloc(strlen(wpt->description) + strlen(wpt->notes) + 9, 1); + notes = (char*) xcalloc(strlen(wpt->description) + strlen(wpt->notes) + 9, 1); sprintf(notes, "%s\nNotes:\n%s", wpt->description, wpt->notes); } else { notes = xstrdup(wpt->description); @@ -371,7 +371,7 @@ coto_wpt_write(const waypoint* wpt) if (notes != NULL) { size += strlen(notes); } - rec = xcalloc(size, 1); + rec = (struct record_wpt*) xcalloc(size, 1); pdb_write_double(&rec->lon, RAD(-wpt->longitude)); pdb_write_double(&rec->lat, RAD(wpt->latitude)); @@ -419,7 +419,7 @@ data_write(void) ff_vecs_t coto_vecs = { ff_type_file, - {ff_cap_read|ff_cap_write, ff_cap_read, ff_cap_none}, + {(ff_cap)(ff_cap_read|ff_cap_write), ff_cap_read, ff_cap_none}, rd_init, wr_init, rd_deinit, diff --git a/gpsbabel/delbin.c b/gpsbabel/delbin.c index 84c07e592..57b847aec 100644 --- a/gpsbabel/delbin.c +++ b/gpsbabel/delbin.c @@ -631,7 +631,7 @@ message_write(unsigned msg_id, message_t* m) chksum = checksum(p + 2, 6); le_write16(p + 8, chksum); // message data (filled in by caller) - chksum = checksum(m->data, m->size); + chksum = checksum((gbuint8*) m->data, m->size); n = 2 + 8 + m->size; // trailer (checksum and marker bytes) le_write16(p + n, chksum); @@ -727,9 +727,9 @@ message_read_1(unsigned msg_id, message_t* m) m->buf[0] = m->buf[1] = 0; memcpy(m->buf + 2, buf, 8); // read message body and trailer - read_depacketize(m->data, total); + read_depacketize((gbuint8*) m->data, total); p = (gbuint8*)m->data + m->size; - if (checksum(m->data, m->size) == le_readu16(p) && + if (checksum((gbuint8*) m->data, m->size) == le_readu16(p) && p[2] == 0xad && p[3] == 0xbc) { if (global_opts.debug_level >= DBGLVL_M) { warning(MYNAME ": received %x\n", id); @@ -862,10 +862,13 @@ get_batch(message_t** array, unsigned* n) return success; } -static struct { +typedef struct { unsigned msg_id; message_t msg; -}* batch_array; +} batch_array_t; + +static batch_array_t* batch_array; + static unsigned batch_array_max; static unsigned batch_array_i; @@ -874,12 +877,12 @@ static void add_to_batch(unsigned id, message_t* m) { if (batch_array_i == batch_array_max) { - void* old = batch_array; + char* old = (char*) batch_array; if (batch_array_max == 0) { batch_array_max = 50; } batch_array_max += batch_array_max; - batch_array = xmalloc(batch_array_max * sizeof(*batch_array)); + batch_array = (batch_array_t*) xmalloc(batch_array_max * sizeof(*batch_array)); if (batch_array_i) { memcpy(batch_array, old, batch_array_i * sizeof(*batch_array)); xfree(old); @@ -2579,7 +2582,11 @@ static void* thread_func(void* run_loop_source) { run_loop = CFRunLoopGetCurrent(); +#if __cplusplus + CFRunLoopAddSource(run_loop, (__CFRunLoopSource*) run_loop_source, kCFRunLoopDefaultMode); +#else CFRunLoopAddSource(run_loop, run_loop_source, kCFRunLoopDefaultMode); +#endif CFRunLoopRun(); return NULL; } @@ -2632,7 +2639,7 @@ mac_os_init(const char* fname) fatal(MYNAME ": IOCreatePlugInInterfaceForService failed 0x%x\n", (int)kr); } IOObjectRelease(service); - hr = (*plugin)->QueryInterface(plugin, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID122), (void*)&device); + hr = (*plugin)->QueryInterface(plugin, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID122), (void**)&device); if (hr) { fatal(MYNAME ": QueryInterface failed 0x%x\n", (int)hr); } diff --git a/gpsbabel/destinator.c b/gpsbabel/destinator.c index 34dc4e39e..116c0c44e 100644 --- a/gpsbabel/destinator.c +++ b/gpsbabel/destinator.c @@ -334,7 +334,7 @@ destinator_read_trk(void) wpt->microseconds = ((int)time % 1000) * 1000; if (wpt->fix > 0) { - wpt->fix++; + wpt->fix = (fix_type)(wpt->fix + 1); } if (! trk) { diff --git a/gpsbabel/garmin_txt.c b/gpsbabel/garmin_txt.c index d79662e50..a6e288f9b 100644 --- a/gpsbabel/garmin_txt.c +++ b/gpsbabel/garmin_txt.c @@ -73,6 +73,18 @@ typedef enum { unknown_header } header_type; +#if __cplusplus +inline header_type operator++(header_type& rs, int) +{ + return rs = (header_type)((int)rs + 1); +} + +inline gt_display_modes_e operator++(gt_display_modes_e& rs, int) +{ + return rs = (gt_display_modes_e)((int)rs + 1); +} +#endif + #define MAX_HEADER_FIELDS 36 static char* header_lines[unknown_header + 1][MAX_HEADER_FIELDS]; @@ -836,7 +848,7 @@ garmin_txt_write(void) xfree(wpt_a); route_idx = 0; - route_info = xcalloc(route_count(), sizeof(struct info_s)); + route_info = (info_t*) xcalloc(route_count(), sizeof(struct info_s)); routepoints = 0; route_disp_all(prework_hdr_cb, prework_tlr_cb, prework_wpt_cb); if (routepoints > 0) { @@ -847,7 +859,7 @@ garmin_txt_write(void) } route_idx = 0; - route_info = xcalloc(track_count(), sizeof(struct info_s)); + route_info = (info_t*) xcalloc(track_count(), sizeof(struct info_s)); routepoints = 0; track_disp_all(prework_hdr_cb, prework_tlr_cb, prework_wpt_cb); @@ -1021,7 +1033,7 @@ bind_fields(const header_type ht) /* make a copy of headers[ht], uppercase, replace "\t" with "\0" */ i = strlen(headers[ht]); - fields = xmalloc(i + 2); + fields = (char*) xmalloc(i + 2); strcpy(fields, headers[ht]); strcat(fields, "\t"); c = strupper(fields); @@ -1325,7 +1337,7 @@ garmin_txt_rd_init(const char* fname) memset(&header_ct, 0, sizeof(header_ct)); datum_index = -1; - grid_index = -1; + grid_index = (grid_type) -1; init_date_and_time_format(); } diff --git a/gpsbabel/gcdb.c b/gpsbabel/gcdb.c index 6f0c2815c..76a744b06 100644 --- a/gpsbabel/gcdb.c +++ b/gpsbabel/gcdb.c @@ -170,13 +170,13 @@ waypt_add(wpt); static int -gcdb_add_to_rec(struct dbrec* rec, const char* fldname, gcdb_rectype rectype, void* data) +gcdb_add_to_rec(struct dbrec* rec, const char* fldname, gcdb_rectype rectype, const void* data) { int length; static int rec_cnt; if (!tbuf) { -tbuf = xcalloc(MAXRECSZ, 1); +tbuf = (char*) xcalloc(MAXRECSZ, 1); tbufp = tbuf; } @@ -195,9 +195,9 @@ strncpy(rec->dbfld[rec_cnt].fldname, fldname, 4); switch (rectype) { case RECTYPE_TEXT: -length = 1 + strlen(data); +length = 1 + strlen((const char*)data); be_write16(&rec->dbfld[rec_cnt].fldlen, length); -strcpy(tbufp, data); +strcpy(tbufp, (const char*)data); tbufp += (length + 1) & (~1); break; case RECTYPE_DATE: @@ -225,7 +225,7 @@ char tbuf[100]; * We don't really know how many fields we'll have or how long * they'll be so we'll just lazily create a huge place to hold them. */ -rec = xcalloc(sizeof(*rec) + 500, 1); +rec = (struct dbrec*) xcalloc(sizeof(*rec) + 500, 1); gcdb_add_to_rec(rec, "gcna", RECTYPE_TEXT, wpt->description); gcdb_add_to_rec(rec, "gcid", RECTYPE_TEXT, wpt->shortname); @@ -273,7 +273,7 @@ gcdb_add_to_rec(rec, "date", RECTYPE_DATE, (void*) wpt->creation_time); /* * We're done. Build the record. */ -reclen = gcdb_add_to_rec(rec, NULL, 0, NULL); +reclen = gcdb_add_to_rec(rec, NULL, (gcdb_rectype)0, NULL); pdb_write_rec(file_out, 0, 2, ct++, rec, reclen); xfree(rec); diff --git a/gpsbabel/gdb.c b/gpsbabel/gdb.c index aa8a6c23e..86100201a 100644 --- a/gpsbabel/gdb.c +++ b/gpsbabel/gdb.c @@ -493,7 +493,7 @@ read_waypoint(gt_waypt_classes_e* waypt_class_out) #if GDB_DEBUG sn = xstrdup(nice(res->shortname)); #endif - wpt_class = FREAD_i32; + wpt_class = (gt_waypt_classes_e) FREAD_i32; GMSD_SET(wpt_class, wpt_class); if (wpt_class != 0) { waypth_ct++; diff --git a/gpsbabel/geoniche.c b/gpsbabel/geoniche.c index 6cd53441d..4e9e0d059 100644 --- a/gpsbabel/geoniche.c +++ b/gpsbabel/geoniche.c @@ -162,7 +162,7 @@ field(char** pp, int* lenp) return NULL; } - dbuf = dp = xmalloc(len); + dbuf = dp = (char*) xmalloc(len); while (len) { char ch; @@ -189,7 +189,7 @@ field(char** pp, int* lenp) } eof: *dp++ = 0; - dbuf = xrealloc(dbuf, dp - dbuf); + dbuf = (char*) xrealloc(dbuf, dp - dbuf); /* fprintf(stderr, "<%.8s> dbuf=%x, len=%d\n", *pp, dbuf, len); */ *pp = p; *lenp = len; @@ -580,11 +580,11 @@ enscape(char* s) char* buf, *d; if (!s) { - d = xmalloc(1); + d = (char*) xmalloc(1); *d = 0; return d; } - buf = d = xmalloc(strlen(s) * 2 + 1); + buf = d = (char*) xmalloc(strlen(s) * 2 + 1); for (; *s; ++s) { /* diff --git a/gpsbabel/ggv_log.c b/gpsbabel/ggv_log.c index 5372b5081..ece06c567 100644 --- a/gpsbabel/ggv_log.c +++ b/gpsbabel/ggv_log.c @@ -103,7 +103,7 @@ ggv_log_read(void) break; } - buf = xmalloc(bufsz); + buf = (signed char*) xmalloc(bufsz); while ((len = gbfread(buf, 1, bufsz, fin))) { int deg, min; diff --git a/gpsbabel/ggv_ovl.c b/gpsbabel/ggv_ovl.c index 169fe94ed..43a293d70 100644 --- a/gpsbabel/ggv_ovl.c +++ b/gpsbabel/ggv_ovl.c @@ -324,7 +324,7 @@ route_disp_cb(const route_head* rte) waypoint* wpt = (waypoint*) elem; if (prev != NULL) { - draw_symbol_basics(OVL_SYMBOL_TRIANGLE, 1, 9 /* color */, prev); + draw_symbol_basics(OVL_SYMBOL_TRIANGLE, 1, (OVL_COLOR_TYP)9 /* color */, prev); gbfprintf(fout, "Width=12\n"); gbfprintf(fout, "Height=8\n"); diff --git a/gpsbabel/gpilots.c b/gpsbabel/gpilots.c index aabdf0bb9..55e04a189 100644 --- a/gpsbabel/gpilots.c +++ b/gpsbabel/gpilots.c @@ -290,7 +290,7 @@ data_read(void) } else { /* name in the form TRACKNAME #n */ snprintf(trk_seg_num_buf, sizeof(trk_seg_num_buf), "%d", trk_seg_num); - track_head->rte_name = xmalloc(strlen(trk_name)+strlen(trk_seg_num_buf)+3); + track_head->rte_name = (char*) xmalloc(strlen(trk_name)+strlen(trk_seg_num_buf)+3); sprintf(track_head->rte_name, "%s #%s", trk_name, trk_seg_num_buf); } trk_seg_num++; @@ -334,7 +334,7 @@ data_read(void) } else { /* name in the form TRACKNAME #n */ snprintf(trk_seg_num_buf, sizeof(trk_seg_num_buf), "%d", trk_seg_num); - track_head->rte_name = xmalloc(strlen(trk_name)+strlen(trk_seg_num_buf)+3); + track_head->rte_name = (char*) xmalloc(strlen(trk_name)+strlen(trk_seg_num_buf)+3); sprintf(track_head->rte_name, "%s #%s", trk_name, trk_seg_num_buf); } trk_seg_num++; @@ -376,7 +376,7 @@ my_write_wpt(const waypoint* wpt) char* vdata; int lat, lon; - rec = xcalloc(sizeof *rec, 1); + rec = (struct record*) xcalloc(sizeof *rec, 1); vdata = (char*)rec + sizeof(*rec); rec->header.type = 4; @@ -421,7 +421,7 @@ data_write(void) ff_vecs_t gpilots_vecs = { ff_type_file, - { ff_cap_read | ff_cap_write, ff_cap_read | ff_cap_write, ff_cap_none}, + { (ff_cap)(ff_cap_read | ff_cap_write), (ff_cap)(ff_cap_read | ff_cap_write), ff_cap_none}, rd_init, wr_init, rd_deinit, diff --git a/gpsbabel/igc.c b/gpsbabel/igc.c index 0dad151e8..2bc7dde78 100644 --- a/gpsbabel/igc.c +++ b/gpsbabel/igc.c @@ -132,6 +132,14 @@ static void rd_deinit(void) gbfclose(file_in); } +typedef enum { id, takeoff, start, turnpoint, finish, landing } state_t; +#if __cplusplus +inline state_t operator++(state_t& rs, int) +{ + return rs = (state_t)((int)rs + 1); +} +#endif + /** * Handle pre- or post-flight task declarations. * A route is created for each set of waypoints in a task declaration. @@ -153,8 +161,7 @@ static void igc_task_rec(const char* rec) char short_name[8]; char tmp_str[MAXRECLEN]; struct tm tm; - - static enum { id, takeoff, start, turnpoint, finish, landing } state = id; + static state_t state = id; // First task record identifies the task to follow if (id == state) { diff --git a/gpsbabel/mag_pdb.c b/gpsbabel/mag_pdb.c index a26c5acce..2eb2b1df8 100644 --- a/gpsbabel/mag_pdb.c +++ b/gpsbabel/mag_pdb.c @@ -110,7 +110,7 @@ magpdb_read_data(const char* data, const size_t data_len) /* now we are looking for a sequence like 0,1 NE (123456,654321) */ - buff = xmalloc(strlen(cin) + 1); /* safe target space for sscanf( ... */ + buff = (char*) xmalloc(strlen(cin) + 1); /* safe target space for sscanf( ... */ comma = cin; while ((comma = strchr(comma, separator))) { diff --git a/gpsbabel/maggeo.c b/gpsbabel/maggeo.c index 27a084722..954729d84 100644 --- a/gpsbabel/maggeo.c +++ b/gpsbabel/maggeo.c @@ -177,7 +177,7 @@ maggeo_fmtdate(time_t t) struct tm* tm = NULL; int date; - char* cbuf = xmalloc(SZ); + char* cbuf = (char*) xmalloc(SZ); cbuf[0] = '\0'; if (t > 0) { diff --git a/gpsbabel/magnav.c b/gpsbabel/magnav.c index f3f639a20..49a6a1e28 100644 --- a/gpsbabel/magnav.c +++ b/gpsbabel/magnav.c @@ -139,7 +139,7 @@ my_writewpt(const waypoint* wpt) mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname; - rec = xcalloc(sizeof(*rec)+56,1); + rec = (struct record*) xcalloc(sizeof(*rec)+56,1); tm = NULL; if (wpt->creation_time) { diff --git a/gpsbabel/mapsend.c b/gpsbabel/mapsend.c index ea1bfe3c8..407e4694f 100644 --- a/gpsbabel/mapsend.c +++ b/gpsbabel/mapsend.c @@ -419,7 +419,9 @@ void mapsend_track_hdr(const route_head* trk) queue* elem, *tmp; char* tname; int i; - mapsend_hdr hdr = {13, "4D533334 MS", "30", ms_type_track, {0, 0, 0}}; + mapsend_hdr hdr = {13, {'4','D','5','3','3','3','3','4',' ','M','S'}, + {'3','0'}, ms_type_track, {0, 0, 0} + }; switch (trk_version) { case 20: @@ -525,7 +527,9 @@ mapsend_track_write(void) static void mapsend_wpt_write(void) { - mapsend_hdr hdr = {13, {"4D533330 MS"}, {"30"}, ms_type_wpt, {0, 0, 0}}; + mapsend_hdr hdr = {13, {'4','D','5','3','3','3','3','0',' ','M','S'}, + {'3', '0'}, ms_type_wpt, {0, 0, 0} + }; int n = 0; int wpt_count = waypt_count(); diff --git a/gpsbabel/mapsource.c b/gpsbabel/mapsource.c index e096b06dc..ecea85cad 100644 --- a/gpsbabel/mapsource.c +++ b/gpsbabel/mapsource.c @@ -67,13 +67,13 @@ static short_handle read_route_wpt_mkshort_handle; #define MPSDESCBUFFERLEN 4096 -char* snlen = NULL; -char* snwhiteopt = NULL; -char* mpsverout = NULL; -char* mpsmergeouts = NULL; -int mpsmergeout; -char* mpsusedepth = NULL; -char* mpsuseprox = NULL; +static char* snlen = NULL; +static char* snwhiteopt = NULL; +static char* mpsverout = NULL; +static char* mpsmergeouts = NULL; +static int mpsmergeout; +static char* mpsusedepth = NULL; +static char* mpsuseprox = NULL; static arglist_t mps_args[] = { diff --git a/gpsbabel/navicache.c b/gpsbabel/navicache.c index 2082745f7..1d9b9eaa4 100644 --- a/gpsbabel/navicache.c +++ b/gpsbabel/navicache.c @@ -160,7 +160,8 @@ nav_start(void* data, const XML_Char* xml_el, const XML_Char** xml_attr) } else if (!strcmp(ap[1], "moving_travelling")) { wpt_tmp->icon_descr = "Geocache-moving"; } else { - xasprintf(&wpt_tmp->icon_descr, + // WARNING: casting away const-ness. + xasprintf((char**)&wpt_tmp->icon_descr, "Geocache-%-.20s", ap[1]); } } else if (0 == strcmp(ap[0], "hidden_date")) { diff --git a/gpsbabel/overlay.c b/gpsbabel/overlay.c index 17166b7f2..93999596c 100644 --- a/gpsbabel/overlay.c +++ b/gpsbabel/overlay.c @@ -415,7 +415,7 @@ static void ovl_rd_deinit(void) } /*------------------------------------------*/ -void ovl_read_parameter(char* fname) +void ovl_read_parameter(const char* fname) { gbfile* fpin; arglist_t* p; diff --git a/gpsbabel/palmdoc.c b/gpsbabel/palmdoc.c index 3b3ff654f..b46581b33 100644 --- a/gpsbabel/palmdoc.c +++ b/gpsbabel/palmdoc.c @@ -253,7 +253,7 @@ static void write_header(void) struct doc_record0 *rec0; --ct; - rec0 = xcalloc(1, sizeof(struct doc_record0)+(ct-1)*sizeof(short)); + rec0 = (struct doc_record0*) xcalloc(1, sizeof(struct doc_record0)+(ct-1)*sizeof(short)); be_write16(&rec0->version, COMPRESSED); be_write16(&rec0->reserved1, 0); be_write32(&rec0->doc_size, offset); @@ -307,7 +307,7 @@ static void write_bookmarks(void) static void commit_buffer(void) { - struct recordsize *newrec = xcalloc(1, sizeof(struct recordsize)); + struct recordsize *newrec = (struct recordsize*) xcalloc(1, sizeof(struct recordsize)); newrec->next = recordsize_tail; newrec->size = buf.len; recordsize_tail = newrec; diff --git a/gpsbabel/pathaway.c b/gpsbabel/pathaway.c index 061e9e32e..340476964 100644 --- a/gpsbabel/pathaway.c +++ b/gpsbabel/pathaway.c @@ -151,7 +151,7 @@ char *ppdb_strcat(char *dest, char *src, char *def, int *size) len = strlen(dest) + strlen(tmp) + 1; if (len > *size) { *size = len; - res = xrealloc(dest, *size); + res = (char*) xrealloc(dest, *size); } else { res = dest; } @@ -197,9 +197,9 @@ char *str_pool_get(size_t size) tmp = str_pool[str_poolp]; if (str_pool_s[str_poolp] == 0) { - tmp = xmalloc(size); + tmp = (char*) xmalloc(size); } else if (str_pool_s[str_poolp] < size) { - tmp = xrealloc(tmp, size); + tmp = (char*) xrealloc(tmp, size); } else { return tmp; } @@ -426,7 +426,7 @@ int ppdb_read_wpt(route_head *head, int isRoute) double altfeet; struct tm tm; - while (pdb_read_rec(file_in, NULL, NULL, NULL, (void *)&data) >= 0) { + while (pdb_read_rec(file_in, NULL, NULL, NULL, (void **)&data) >= 0) { waypoint *wpt_tmp = waypt_new(); int line = 0; char *tmp = data; @@ -654,7 +654,7 @@ static void ppdb_write_wpt(const waypoint *wpt) int len; struct tm tm; - buff = xcalloc(REC_SIZE, 1); + buff = (char *) xcalloc(REC_SIZE, 1); if (wpt->latitude < 0) { latdir = 'S'; @@ -752,7 +752,7 @@ static void ppdb_write(void) * if (global_opts.objective != wptdata) / * Waypoint target do not need appinfo block * / * { */ - appinfo = xcalloc(1, sizeof(*appinfo)); + appinfo = (ppdb_appdata_t *) xcalloc(1, sizeof(*appinfo)); file_out->appinfo = (void *)appinfo; file_out->appinfo_len = PPDB_APPINFO_SIZE; /* } diff --git a/gpsbabel/pdbfile.c b/gpsbabel/pdbfile.c index 78205fe4d..0b6af46f0 100644 --- a/gpsbabel/pdbfile.c +++ b/gpsbabel/pdbfile.c @@ -63,15 +63,15 @@ pdb_read_tail(gbfile *fin, gbuint32 *size) res = (char *) xmalloc(count); memcpy(res, buff, count); } else { - res = xrealloc(res, bytes + count); + res = (char*) xrealloc(res, bytes + count); memcpy(&res[bytes], buff, count); } bytes += count; } if (res) { - res = xrealloc(res, bytes + 1); + res = (char*) xrealloc(res, bytes + 1); } else { - res = xmalloc(1); + res = (char*) xmalloc(1); } res[bytes] = '\0'; @@ -133,7 +133,7 @@ pdb_load_data(pdbfile *fin) for (i = 0; i < ct; i++) { pdbrec_t *rec; - rec = xcalloc(1, sizeof(*rec)); + rec = (pdbrec_t*) xcalloc(1, sizeof(*rec)); if (fin->attr & PDB_FLAG_RESOURCE) { (void) gbfgetuint32(fin->file); /* type */ rec->id = gbfgetint16(fin->file); @@ -205,14 +205,14 @@ pdb_load_data(pdbfile *fin) if (rec->next) { rec->size = (gbint32)rec->next->offs - (gbint32)offs; if (rec->size > 0) { - rec->data = xmalloc(rec->size); + rec->data = (char*) xmalloc(rec->size); rec->size = gbfread(rec->data, 1, rec->size, fin->file); offs += rec->size; } else if (rec->size < 0) { pdb_invalid_file(fin, "Wrong data size in record with id %d.\n", rec->id); } } else { - rec->data = pdb_read_tail(fin->file, &rec->size); + rec->data = (char*) pdb_read_tail(fin->file, &rec->size); offs += rec->size; } } @@ -223,7 +223,7 @@ pdb_open(const char *filename, const char *module) { pdbfile *res; - res = xcalloc(1, sizeof(*res)); + res = (pdbfile*) xcalloc(1, sizeof(*res)); res->file = gbfopen_be(filename, "rb", module); res->mode = 1; @@ -260,7 +260,7 @@ pdb_create(const char *filename, const char *module) { pdbfile *res; - res = xcalloc(1, sizeof(*res)); + res = (pdbfile*) xcalloc(1, sizeof(*res)); strncpy(res->name, "Palm/OS Database", PDB_DBNAMELEN); res->file = gbfopen_be(filename, "wb", module);; res->mode = 2; @@ -273,13 +273,13 @@ pdb_write_rec(pdbfile *fout, const gbuint8 flags, const gbuint8 category, const { pdbrec_t *rec, *cur; - rec = xcalloc(1, sizeof(*rec)); + rec = (pdbrec_t*) xcalloc(1, sizeof(*rec)); rec->category = category; rec->flags = category; rec->id = rec_id; rec->size = size; if (size > 0) { - rec->data = xmalloc(size); + rec->data = (char*) xmalloc(size); memcpy(rec->data, data, size); } diff --git a/gpsbabel/pocketfms_bc.c b/gpsbabel/pocketfms_bc.c index fb71eb1a2..e7f788492 100755 --- a/gpsbabel/pocketfms_bc.c +++ b/gpsbabel/pocketfms_bc.c @@ -114,7 +114,7 @@ read_tracks(void) wpt->pdop = le_read_float(&bc.espe); wpt->course = le_read_float(&bc.course); wpt->speed = le_read_float(&bc.speed); - wpt->fix = (fix_type) le_readu16(&bc.fix) - 1; + wpt->fix = (fix_type) (le_readu16(&bc.fix) - 1); track_add_wpt(trk_head, wpt); } diff --git a/gpsbabel/shape.c b/gpsbabel/shape.c index e8b6269ae..965ac7a04 100644 --- a/gpsbabel/shape.c +++ b/gpsbabel/shape.c @@ -278,9 +278,9 @@ void poly_init(const route_head *h) { int ct = track_waypt_count(); - polybufx = xcalloc(ct, sizeof(double)); - polybufy = xcalloc(ct, sizeof(double)); - polybufz = xcalloc(ct, sizeof(double)); + polybufx = (double*) xcalloc(ct, sizeof(double)); + polybufy = (double*) xcalloc(ct, sizeof(double)); + polybufz = (double*) xcalloc(ct, sizeof(double)); } diff --git a/gpsbabel/skytraq.c b/gpsbabel/skytraq.c index bf6af7ff3..b98057583 100644 --- a/gpsbabel/skytraq.c +++ b/gpsbabel/skytraq.c @@ -244,7 +244,7 @@ wr_buf(const unsigned char *str, int len) gbuint8 NL[2] = { 0x0D, 0x0A }; gbuint8 MSG_START[2] = { 0xA0, 0xA1 }; -gbuint8 SECTOR_READ_END[13] = "END\0CHECKSUM="; +gbuint8 SECTOR_READ_END[] = "END\0CHECKSUM="; static int skytraq_calc_checksum(const unsigned char *buf, int len) @@ -288,9 +288,9 @@ skytraq_rd_msg(const void *payload, int len) } db(2, "Receiving message with %i bytes of payload (expected >=%i)\n", rcv_len, len); - rd_buf(payload, MIN(rcv_len, len)); + rd_buf((const unsigned char*) payload, MIN(rcv_len, len)); - calc_cs = skytraq_calc_checksum(payload, MIN(rcv_len, len)); + calc_cs = skytraq_calc_checksum((const unsigned char*) payload, MIN(rcv_len, len)); for (i = 0; i < rcv_len-len; i++) { c = rd_char(&errors); calc_cs ^= c; @@ -507,7 +507,7 @@ static unsigned int me_read32(const unsigned char *p) } struct read_state { - route_head *route_head; + route_head *route_head_; unsigned wpn, tpn; time_t ts; @@ -524,7 +524,7 @@ state_init(struct read_state *pst) track->rte_desc = xstrdup("SkyTraq GPS tracklog data"); track_add_head(track); - pst->route_head = track; + pst->route_head_ = track; pst->wpn = 0; pst->tpn = 0; @@ -709,13 +709,13 @@ process_data_item(struct read_state *pst, const item_frame *pitem, int len) waypt_add(waypt_dupe(tpt)); } - if (0 == pst->route_head) { + if (0 == pst->route_head_) { db(1, MYNAME ": New Track\n"); - pst->route_head = route_head_alloc(); - track_add_head(pst->route_head); + pst->route_head_ = route_head_alloc(); + track_add_head(pst->route_head_); } - track_add_wpt(pst->route_head, tpt); + track_add_wpt(pst->route_head_, tpt); } return res; diff --git a/gpsbabel/stmsdf.c b/gpsbabel/stmsdf.c index 6991f89d9..ea6b51565 100644 --- a/gpsbabel/stmsdf.c +++ b/gpsbabel/stmsdf.c @@ -190,7 +190,7 @@ finalize_tracks(void) return; } - list = (void *)xmalloc(count * sizeof(*list)); + list = (waypoint**)xmalloc(count * sizeof(*list)); index = 0; QUEUE_FOR_EACH(&trackpts, elem, tmp) { @@ -795,8 +795,8 @@ ff_vecs_t stmsdf_vecs = { ff_type_file, { ff_cap_none, - ff_cap_read | ff_cap_write, - ff_cap_read | ff_cap_write + (ff_cap)(ff_cap_read | ff_cap_write), + (ff_cap)(ff_cap_read | ff_cap_write) }, rd_init, wr_init, diff --git a/gpsbabel/stmwpp.c b/gpsbabel/stmwpp.c index b7a3794e9..b3c703397 100644 --- a/gpsbabel/stmwpp.c +++ b/gpsbabel/stmwpp.c @@ -81,7 +81,7 @@ stmwpp_data_read(void) what = STM_NOTHING; buff = gbfgetstr(fin); - buff = (buff == NULL) ? "" : buff; + buff = (buff == NULL) ? (char *) "" : buff; if (case_ignore_strncmp(buff, "Datum,WGS 84,WGS 84,", 20) != 0) { fatal(MYNAME ": Invalid GPS datum or not \"WaypointPlus\"\" file!\n"); -- 2.30.2